package cn.com.lms.business.learning.persistence.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.ToString;

import javax.persistence.*;
import javax.swing.*;
import java.util.Date;
import java.util.Objects;

@Entity

@ToString(callSuper = true)
@Table(name = "bnz_learning_stage_detail", schema = "bnzj", catalog = "")
public class FbLearningStageDetail {
    private long id;
    @Schema(description = "所属阶段id")
    private Long stageId;
    @Schema(description = "学习类型id")
    private Long objId;
    @Schema(description = "学习类型 0课程 1问卷 2试卷")
    private String studyType;
    @Schema(description = "试卷时长")
    private int studyTime;
    @Schema(description = "试卷总分数")
    private Integer paperScore;
    @Schema(description = "通过分数")
    private int adoptScore;
    @Schema(description = "试卷限考次数")
    private Integer limitNum;
    @Schema(description = "已完成任务数")
    private Integer finishNum;
    @Schema(description = "任务数")
    private Integer unFinish;
    @Schema(description = "课程、试卷，问卷名称")
    private String objName;
    @Schema(description = "试卷，问卷自定义名称")
    private String objTitle;
    @Schema(description = "学习计划id")
    private Long planId;
    @Schema(description = "课程封面图")
    private String pictureUrl;
    @Schema(description = "课程类型")
    private String courseType;
    @Schema(description = "课程时间")
    private int courseTime;
    @Schema(description = "计划名称")
    private String planName;
    @Schema(description = "创建时间")
    private String createTime;
    @Schema(description = "学习时长")
    private Number learningHours;
    @Schema(description = "直播开始时间")
    private Date liveStartTime;
    @Schema(description = "直播实际开始时间")
    private Date liveRealStartTime;
    @Schema(description = "直播时间")
    private int liveStatus;
    @Schema(description = "完成状态0否 1是")
    private String finishState;

    @Id
    @Column(name = "id")
    @GeneratedValue(
            strategy = GenerationType.IDENTITY
    )
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "stage_id")
    public Long getStageId() {
        return stageId;
    }

    public void setStageId(Long stageId) {
        this.stageId = stageId;
    }

    @Basic
    @Column(name = "obj_id")
    public Long getObjId() {
        return objId;
    }

    public void setObjId(Long objId) {
        this.objId = objId;
    }

    @Basic
    @Column(name = "study_type")
    public String getStudyType() {
        return studyType;
    }

    public void setStudyType(String studyType) {
        this.studyType = studyType;
        if ("1".equals(studyType)) {
            this.courseType = "问卷";
        } else if ("2".equals(studyType)) {
            this.courseType = "试卷";
        }
    }

    @Transient
    public Integer getPaperScore() {
        return paperScore;
    }

    public void setPaperScore(Integer paperScore) {
        this.paperScore = paperScore;
    }

    @Basic
    @Column(name = "study_time")
    public int getStudyTime() {
        return studyTime;
    }

    public void setStudyTime(int studyTime) {
        this.studyTime = studyTime;
    }

    @Basic
    @Column(name = "adopt_score")
    public int getAdoptScore() {
        return adoptScore;
    }

    public void setAdoptScore(int adoptScore) {
        this.adoptScore = adoptScore;
    }

    @Basic
    @Column(name = "limit_num")
    public Integer getLimitNum() {
        return limitNum;
    }

    public void setLimitNum(Integer limitNum) {
        this.limitNum = limitNum;
    }

    @Basic
    @Column(name = "plan_id")
    public Long getPlanId() {
        return planId;
    }

    public void setPlanId(Long planId) {
        this.planId = planId;
    }

    @Basic
    @Column(name = "obj_name")
    public String getObjName() {
        return objName;
    }

    public void setObjName(String objName) {
        this.objName = objName;
    }

    @Transient
    public String getPictureUrl() {
        return pictureUrl;
    }

    public void setPictureUrl(String pictureUrl) {
        this.pictureUrl = pictureUrl;
    }

    @Transient
    public String getObjTitle() {
        return objTitle;
    }

    public void setObjTitle(String objTitle) {
        this.objTitle = objTitle;
    }

    @Transient
    public Integer getFinishNum() {
        return finishNum;
    }

    public void setFinishNum(Integer finishNum) {
        this.finishNum = finishNum;
    }

    @Transient
    public Integer getUnFinish() {
        return unFinish;
    }

    public void setUnFinish(Integer unfinish) {
        this.unFinish = unfinish;
    }

    @Transient
    public String getCourseType() {
        return courseType;
    }

    public void setCourseType(String courseType) {
        this.courseType = courseType;
    }

    @Transient
    public int getCourseTime() {
        return courseTime;
    }

    public void setCourseTime(int courseTime) {
        this.courseTime = courseTime;
    }

    @Transient
    public String getPlanName() {
        return planName;
    }

    public void setPlanName(String planName) {
        this.planName = planName;
    }

    @Transient
    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    @Transient
    public Number getLearningHours() {
        return learningHours;
    }

    public void setLearningHours(Number learningHours) {
        this.learningHours = learningHours;
    }

    @Transient
    public Date getLiveStartTime() {
        return liveStartTime;
    }

    public void setLiveStartTime(Date liveStartTime) {
        if (null != liveStartTime) {
            this.liveStartTime = liveStartTime;
        }
    }

    @Transient
    public Date getLiveRealStartTime() {
        return liveRealStartTime;
    }

    public void setLiveRealStartTime(Date liveRealStartTime) {
        this.liveRealStartTime = liveRealStartTime;
    }

    @Transient
    public int getLiveStatus() {
        return liveStatus;
    }

    public void setLiveStatus(int liveStatus) {
        this.liveStatus = liveStatus;
    }

    @Transient
    public String getFinishState() {
        return finishState;
    }

    public void setFinishState(String finishState) {
        this.finishState = finishState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FbLearningStageDetail detail = (FbLearningStageDetail) o;
        return id == detail.id &&
                studyTime == detail.studyTime &&
                adoptScore == detail.adoptScore &&
                Objects.equals(stageId, detail.stageId) &&
                Objects.equals(objId, detail.objId) &&
                Objects.equals(studyType, detail.studyType) &&
                Objects.equals(finishNum, detail.finishNum) &&
                Objects.equals(unFinish, detail.unFinish) &&
                Objects.equals(objName, detail.objName) &&
                Objects.equals(planId, detail.planId) &&
                Objects.equals(courseType, detail.courseType) &&
                Objects.equals(planName, detail.planName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, stageId, objId, studyType, studyTime, adoptScore, finishNum, unFinish, objName, planId, courseType, planName);
    }
}
